home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-11 | 12.9 KB | 424 lines | [TEXT/MPS ] |
- /*
- File: Palette.h
-
- Contains: Palette Classes Definition
-
- Written by: Dave Stafford
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- // -- DrawEditor Includes --
-
- #ifndef _SHAPES_
- #define _SHAPES_
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- #ifndef _DRAWEDITORGLOBALS_
- #include "DrawEditorGlobals.h"
- #endif
-
- #ifndef _DRAWEDITORDEF_
- #include "DrawEditorDef.h"
- #endif
-
- #ifndef _PALETTE_
- #include "Palette.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdDefs_defined
- #include <StdDefs.xh>
- #endif
-
-
- //=============================================================================
- // Forward Declarations
- //=============================================================================
- class CPublishLink;
- class CSubscribeLink;
- class CEmbeddedFrameProxy;
- class COrderedList;
- class CCloneInfo;
-
- //=============================================================================
- // Constants
- //=============================================================================
-
- // ----- handles -----
- const short kInTopLeftCorner = 1;
- const short kInBottomRightCorner = kInTopLeftCorner + 1;
- const short kInTopRightCorner = kInBottomRightCorner + 1;
- const short kInBottomLeftCorner = kInTopRightCorner + 1;
-
- const short kNumberOfHandles = 4;
-
- //=============================================================================
- // Enumerations
- //=============================================================================
-
- // Make shape IDs map to tool IDs
- // kEmbeddingShape can equate to the text tool since it is the only tool which
- // causes a part to be embedded directly.
- enum {
- kRectShape = kRectangleTool,
- kLineShape = kLineShapeTool,
- kOvalShape = kOvalTool,
- kPolygonShape = kPolygonTool,
- kEmbeddingShape = kTextTool
- };
-
- //=============================================================================
- // CShape
- //=============================================================================
- class CShape
- {
- public:
-
- // -- Init --
- CShape(ODSShort numberOfHandles, ODSShort shapeType);
-
- public:
- virtual ~CShape();
-
- public:
-
- // -- Accessors --
- virtual ODBoolean IsFrozen() const;
- virtual ODSShort GetShapeType() const;
-
- // We must remember if we were promised to the clipboard
- // because users cannot modify shapes that are promised.
- ODBoolean IsPromisedToClipboard() const;
- void SetPromisedToClipboard(ODBoolean promised);
-
- ODBoolean GetCanDrawColor();
- void SetCanDrawColor(ODBoolean toggle);
- void SetColor(const CRGBColor& color);
- CRGBColor* GetColor();
-
- virtual ODRgnHandle GetBoundingRegion() const;
- virtual void GetBoundingBox(Rect* bounds) const;
- virtual void GetBoundingBox(ODRect* bounds) const;
-
- virtual void SetBoundingBox(Environment* ev, const Point& anchorPoint, const Point& currentPoint);
- virtual void SetBoundingBox(Environment* ev, const Rect& bounds);
- virtual void SetBoundingBox(Environment* ev, ODShape* bounds);
-
- virtual void GetUpdateShape(Environment* ev, ODShape* updateShape) const;
- virtual void GetUpdateBox(Environment* ev, ODRect* updateBox) const;
-
- // ----- Embedding Protocols
- virtual ODBoolean ContainsProxyForFrame(Environment* ev, ODFrame* frame);
- virtual void SetInLimbo(Environment* ev, ODBoolean isInLimbo);
-
- // ----- Dragging
- virtual void OffsetShape(Environment *ev, ODCoordinate xDelta, ODCoordinate yDelta);
- virtual ODShape* CreateDragShape(Environment *ev, ODFacet* facet) = 0;
- virtual void GetDragRect(Rect* dragRect) const;
-
- // ----- Drawing -----
- void InvalidateHandles(Environment *ev, ODFrame* frame);
- virtual void DrawShape(Environment* ev, ODFacet* facet);
- void DrawHandles();
- virtual void OutlineShape(ODFacet* facet, const Rect& rect, ODBoolean draw) = 0;
-
- virtual void Show(Environment* ev, ODBoolean shown);
- ODBoolean IsShown();
-
-
- // ----- Selection / Activation -----
- virtual ODBoolean HitTest(Environment *ev, const Point& where) const = 0;
- ODBoolean ShapeInRectangle(const Rect& rect) const; // InSelectionRect
-
- virtual void SelectShape(Environment* ev, ODBoolean state);
- virtual void Activate(Environment* ev, ODBoolean activating, ODFrame* frame);
- ODBoolean IsSelected() const
- {return fSelected;}
-
- // ----- Handles -----
- ODSShort WhichHandle(const Point& mouse) const;
- void CalcHandle(short whichHandle, Rect* bounds) const;
- virtual void GetHandleCenter(short whichHandle, Point* center) const;
-
- // ----- Resize -----
- virtual void Resize(Environment *ev, Rect& baseRect, Rect& resizeRect);
- virtual void ResizeFeedback(ODFacet* facet, short whichHandle, Point& mouseLoc, ODBoolean draw);
-
- virtual void GetResizeRect(ODSShort whichHandle,
- Point& lastLocation,
- Rect* srcRect,
- Rect* dstRect);
-
- virtual ODBoolean SetFrozen(ODBoolean state);
-
- // ----- OpenDoc Notifications -----
- virtual void Open(Environment *ev, ODFrame* container);
-
- virtual void DisplayFrameConnected(Environment *ev, ODFrame* frame);
- virtual void DisplayFrameAdded(Environment *ev, ODFrame* frame);
- virtual void DisplayFrameRemoved(Environment *ev, ODFrame* frame);
- virtual void DisplayFrameClosed(Environment *ev, ODFrame* frame);
-
- virtual void Dragging(Environment *ev, ODBoolean dragging);
- virtual void FacetAdded(Environment *ev, ODFacet* facet);
- virtual void FacetRemoved(Environment *ev, ODFacet* facet);
-
- // ----- DrawEditor Notifications -----
- virtual void Added(Environment *ev);
- virtual void Removed(Environment *ev, ODBoolean commit);
-
- // ----- Z Ordering -----
- void MoveBefore(Environment* ev, CShape* before);
- void MoveAfter(Environment* ev, CShape* after);
-
- // ----- Linking -----
- virtual void Publish(Environment* ev, CPublishLink *publishLink);
- virtual void Subscribe(Environment* ev, CSubscribeLink* link);
- virtual void Unpublish(Environment* ev, CPublishLink* publishLink);
- virtual void Unsubscribe(Environment* ev);
-
- COrderedList* GetPublishLinks() const
- {return fPublishLinks;}
-
- ODBoolean IsPublished();
-
- void SetSubscribeLink(CSubscribeLink *subscribeLink)
- {fSubscribeLink = subscribeLink;}
- CSubscribeLink* GetSubscribeLink() const
- {return fSubscribeLink;}
- ODBoolean IsSubscribed() const
- {return fSubscribeLink != NULL;}
-
- // ----- Storage -----
- virtual void Read(Environment* ev, ODStorageUnitView* view, CCloneInfo* cloneInfo);
- virtual void Read(Environment* ev, ODStorageUnit* storage, CCloneInfo* cloneInfo);
- virtual void Write(Environment* ev, ODStorageUnit* storage, CCloneInfo* cloneInfo);
- virtual void Write(Environment* ev, ODStorageUnitView* view, CCloneInfo* cloneInfo);
-
- void SetExternalizationIndex(ODUShort index);
- ODUShort GetExternalizationIndex();
-
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- Rect fRect;
- COrderedList* fPublishLinks;
- CSubscribeLink* fSubscribeLink;
-
- private:
-
- CRGBColor fColor;
- ODBoolean fCanDrawColor;
-
- ODBoolean fSelected;
- ODBoolean fPromisedToClipboard;
- ODBoolean fShown;
-
- ODSShort fShapeType;
- ODSShort fNumberOfHandles;
-
- ODUShort fExternalizationIndex;
-
- };
-
-
- //=============================================================================
- // class CRectangleShape
- //=============================================================================
-
- class CRectangleShape : public CShape
- {
- public:
- CRectangleShape(ODSShort shapeType = kRectShape);
- virtual ~CRectangleShape();
-
- // ----- Shape -----
- virtual ODShape* CreateDragShape(Environment *ev, ODFacet* facet);
-
- virtual void OutlineShape(ODFacet* facet, const Rect& rect, ODBoolean draw);
-
- virtual ODBoolean HitTest(Environment *ev, const Point& where) const;
- virtual void DrawShape(Environment* ev, ODFacet* facet);
-
- };
-
-
-
- //=============================================================================
- // class COvalShape
- //=============================================================================
-
- class COvalShape : public CShape
- {
- public:
- COvalShape();
- virtual ~COvalShape();
-
- // ----- Shape -----
- virtual ODShape* CreateDragShape(Environment *ev, ODFacet* facet);
- virtual ODRgnHandle GetBoundingRegion() const;
-
- virtual void OutlineShape(ODFacet* facet, const Rect& rect, ODBoolean draw);
-
- virtual ODBoolean HitTest(Environment *ev, const Point& where) const;
- virtual void DrawShape(Environment* ev, ODFacet* facet);
-
- };
-
-
- //=============================================================================
- // class CPolygonShape
- //=============================================================================
-
- class CPolygonShape : public CShape
- {
- public:
- CPolygonShape();
- virtual ~CPolygonShape();
-
- // ----- Inherited API -----
-
- // Shape
- virtual ODShape* CreateDragShape(Environment *ev, ODFacet* facet);
- virtual ODRgnHandle GetBoundingRegion() const;
-
- virtual void Resize(Environment *ev, Rect& baseRect, Rect& resizeRect);
-
- virtual void OutlineShape(ODFacet* facet, const Rect& rect, ODBoolean draw);
-
- virtual ODBoolean HitTest(Environment *ev, const Point& where) const;
- virtual void DrawShape(Environment* ev, ODFacet* facet);
-
- virtual void OffsetShape(Environment *ev, ODCoordinate xDelta, ODCoordinate yDelta);
-
- // Storage
- virtual void Read(Environment* ev, ODStorageUnit* storage, CCloneInfo* cloneInfo);
-
- // ----- New API -----
-
- virtual void SetPolygon(ODSShort numSides);
-
- private:
- PolyHandle fPolygon;
- ODSShort fSides;
-
- };
-
-
-
- //=============================================================================
- // class CEmbeddingShape
- //=============================================================================
-
- class CEmbeddingShape : public CRectangleShape
- {
- public:
- CEmbeddingShape(DrawEditor* drawEditor);
- virtual ~CEmbeddingShape();
-
- // ----- Inherited Methods -----
- virtual void DrawShape(Environment* ev, ODFacet* facet);
- virtual void SelectShape(Environment* ev, ODBoolean state);
-
- virtual void OffsetShape( Environment *ev,
- ODCoordinate xDelta,
- ODCoordinate yDelta);
-
- // ----- Embedding Protocols
- virtual ODBoolean ContainsProxyForFrame(Environment* ev, ODFrame* frame);
- ODFacet* GetEmbeddedFacet(Environment* ev, ODFacet* containingFacet);
- ODFacet* GetEmbeddedFacet(Environment* ev, ODFrame* containingFrame);
- ODFrame* GetAnyFrame(Environment* ev);
-
- void AddFrameProxy(CEmbeddedFrameProxy* frameProxy);
-
- void Embed( Environment* ev,
- ODPart* part,
- ODFrame* containingFrame,
- ODID embeddedFrame);
-
- virtual void SetInLimbo(Environment* ev, ODBoolean isInLimbo);
- virtual ODBoolean SetFrozen(ODBoolean state);
-
- // ----- Drawing -----
- virtual void Show(Environment* ev, ODBoolean shown);
-
-
- virtual void SetBoundingBox(Environment* ev, const Point& anchorPoint, const Point& currentPoint);
- virtual void SetBoundingBox(Environment* ev, const Rect& bounds);
- virtual void SetBoundingBox(Environment* ev, ODShape* bounds);
-
- virtual void SetShapeRectangle(Environment* ev, ODShape* bounds);
-
- virtual void SetProxyBounds(Environment* ev, const Rect& bounds);
-
- // ----- Z Ordering -----
- void MoveFirst(Environment* ev);
- void MoveLast(Environment* ev);
- void MoveBefore(Environment* ev, CShape* before);
- void MoveAfter(Environment* ev, CShape* behind);
-
-
- // ----- Activation -----
- virtual void Activate(Environment* ev, ODBoolean activating, ODFrame* frame);
-
- // ----- Resize -----
- virtual void Resize(Environment* ev, Rect& baseRect, Rect& resizeRect);
-
- // ----- OpenDoc Notifications -----
- virtual void Open(Environment *ev, ODFrame* container);
-
- virtual void DisplayFrameConnected(Environment *ev, ODFrame* frame);
- virtual void DisplayFrameAdded(Environment *ev, ODFrame* frame);
- virtual void DisplayFrameRemoved(Environment *ev, ODFrame* frame);
- virtual void DisplayFrameClosed(Environment *ev, ODFrame* frame);
-
-
- virtual void Dragging(Environment *ev, ODBoolean dragging);
- virtual void FacetAdded(Environment *ev, ODFacet* facet);
- virtual void FacetRemoved(Environment *ev, ODFacet* facet);
-
- // ----- DrawEditor Notifications -----
- virtual void Added(Environment *ev);
- virtual void Removed(Environment *ev, ODBoolean commit);
-
- // ----- Storage -----
- virtual void Read(Environment* ev, ODStorageUnitView* view, CCloneInfo* cloneInfo);
- virtual void Read(Environment* ev, ODStorageUnit* storage, CCloneInfo* cloneInfo);
- virtual void Write(Environment* ev, ODStorageUnit* storage, CCloneInfo* cloneInfo);
- virtual void Write(Environment* ev, ODStorageUnitView* view, CCloneInfo* cloneInfo);
-
- // ----- Linking ------
- virtual void Publish(Environment* ev, CPublishLink* link);
- virtual void Subscribe(Environment* ev, CSubscribeLink* link);
-
- void ChangeLinkStatus(Environment* ev, ODLinkStatus linkStatus);
- virtual void Unpublish(Environment* ev, CPublishLink* link);
- virtual void Unsubscribe(Environment* ev);
-
- private:
- DrawEditor* fDrawEditor;
-
- ODBoolean fFrozen;
-
- COrderedList* fFrameProxies;
- ODRect fFrameRect;
-
- };
-
-
-
-
- #endif